package com.fan.base.aspect;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.alibaba.fastjson.JSONObject;

public class ServiceLogAspect {
	private final static Logger LOGGER = LoggerFactory.getLogger(ServiceLogAspect.class);
	
	public void beforHandler(JoinPoint joinpoint) {
		LOGGER.info(JSONObject.toJSONString(joinpoint.getArgs()));
		System.out.println("hello");
	}
	
	public void afterHandler() {
		System.out.println("after");
	}
	public  Object aroundHandler(ProceedingJoinPoint joinPoint) {
		Object returnObject = null;
		try {
			LOGGER.info("请求参数"+JSONObject.toJSONString(joinPoint.getArgs()));
			returnObject = joinPoint.proceed();
			LOGGER.info("响应参数:"+JSONObject.toJSONString(returnObject));
		} catch (Throwable e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		System.out.println("aroud");
		return returnObject;
	}

}
